import Vue from 'vue'

// 重置浏览器默认css样式
import 'normalize.css/normalize.css' // A modern alternative to CSS resets

// 导入element组件库
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// import locale from 'element-ui/lib/locale/lang/en' // lang i18n

// 导入项目的全局样式
import '@/styles/index.scss' // global css

// 导入根组件
import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon 加载内置图标文件
// 添加路由拦截(保安)
import '@/permission' // permission control

// 1.导入全局指令
import * as directs from '@/directives'
console.log('导入所有指令对象:', directs)
// 2.注册全局指令(批量注册多个)
Object.keys(directs).forEach(name => {
  // 批量注册多个指令
  Vue.directive(name, directs[name])
})

/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */
// if (process.env.NODE_ENV === 'production') {
//   const { mockXHR } = require('../mock')
//   mockXHR()
// }

// set ElementUI lang to EN
// 注册组件库
Vue.use(ElementUI)
// 如果想要中文版 element-ui，按如下方式声明
// Vue.use(ElementUI)

// 获取环境变量
console.log('获取环境变量:', process.env)

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
